<%@ page language="java" import="java.util.*"
	contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/context/mytags.jsp"%>
<!DOCTYPE html>
<html>
<head>
<title>微信客服账号</title>
<t:base type="jquery,easyui,tools,DatePicker"></t:base>
<link rel="stylesheet" href="plug-in/uploadify/css/uploadify.css"
	type="text/css" />
<script type="text/javascript"
	src="plug-in/uploadify/jquery.uploadify-3.1.js"></script>
<script type="text/javascript">
  //编写自定义JS代码
</script>
</head>
<body>
	<t:formvalid formid="formobj" dialog="true" usePlugin="password"
		layout="table" action="wxKfAccountController.do?doAdd" tiptype="1"
		callback="jeecgFormFileCallBack@Override" beforeSubmit="beforeSubmit">
		<input id="id" name="id" type="hidden" value="${wxKfAccountPage.id }">
		<input id="createName" name="createName" type="hidden"
			value="${wxKfAccountPage.createName }">
		<input id="createBy" name="createBy" type="hidden"
			value="${wxKfAccountPage.createBy }">
		<input id="createDate" name="createDate" type="hidden"
			value="${wxKfAccountPage.createDate }">
		<input id="updateName" name="updateName" type="hidden"
			value="${wxKfAccountPage.updateName }">
		<input id="updateBy" name="updateBy" type="hidden"
			value="${wxKfAccountPage.updateBy }">
		<input id="updateDate" name="updateDate" type="hidden"
			value="${wxKfAccountPage.updateDate }">
		<input id="sysOrgCode" name="sysOrgCode" type="hidden"
			value="${wxKfAccountPage.sysOrgCode }">
		<input id="sysCompanyCode" name="sysCompanyCode" type="hidden"
			value="${wxKfAccountPage.sysCompanyCode }">
		<input id="accountId" name="accountId" type="hidden"
			value="${wxKfAccountPage.accountId }">
		<input id="headImgWxUrl" name="headImgWxUrl" type="hidden"
			value="${wxKfAccountPage.headImgWxUrl }">
		<input id="headImgMediaId" name="headImgMediaId" type="hidden"
			value="${wxKfAccountPage.headImgMediaId }">
		<table style="width: 600px;" cellpadding="0" cellspacing="1"
			class="formtable">
			<tr>
				<td align="right"><label class="Validform_label"> 账号: </label>
				</td>
				<td class="value"><input id="username" name="username"
					type="text" style="width: 150px" class="inputxt" datatype="*"
					autocomplete="off"> <span class="Validform_checktip"></span>
					<label class="Validform_label" style="display: none;">账号</label></td>
			</tr>
			<tr>
				<td align="right"><label class="Validform_label"> 密码: </label>
				</td>
				<td class="value"><input id="password" name="password"
					type="password" style="width: 150px" class="inputxt"
					autocomplete="off"> <span class="Validform_checktip"></span>
					<label class="Validform_label" style="display: none;">密码</label></td>
			</tr>
			<tr>
				<td align="right"><label class="Validform_label"> 确认密码:
				</label></td>
				<td class="value"><input id="confirmpwd" name="confirmpwd"
					type="password" style="width: 150px" class="inputxt"
					autocomplete="off"> <span class="Validform_checktip"></span>
					<label class="Validform_label" style="display: none;">确认密码</label></td>
			</tr>
			<tr>
				<td align="right"><label class="Validform_label"> 昵称: </label>
				</td>
				<td class="value"><input id="nickName" name="nickName"
					type="text" style="width: 150px" class="inputxt"> <span
					class="Validform_checktip"></span> <label class="Validform_label"
					style="display: none;">昵称</label></td>
			</tr>
			<tr>
				<td align="right"><label class="Validform_label">
						头像本地地址: </label></td>
				<td class="value">
					<table></table>
					<div class="form jeecgDetail">
						<script type="text/javascript">
              var serverMsg = "";
              $(function() {
                $('#headImgLocalUrl').uploadify(
                    {
                      buttonText : '添加文件',
                      auto : false,
                      progressData : 'speed',
                      multi : true,
                      height : 25,
                      overrideEvents : [ 'onDialogClose' ],
                      fileTypeDesc : '文件格式:',
                      queueID : 'filediv_file',
                      fileTypeExts : '*.jpg;*.gif;*.png',
                      fileSizeLimit : '15MB',
                      swf : 'plug-in/uploadify/uploadify.swf',
                      uploader : 'cgUploadController.do?saveFiles&jsessionid='
                          + $("#sessionUID").val() + '',
                      onUploadStart : function(file) {
                        var cgFormId = $("input[name='id']").val();
                        $('#headImgLocalUrl').uploadify("settings", "formData",
                            {
                              'cgFormId' : cgFormId,
                              'cgFormName' : 'wx_kf_account',
                              'cgFormField' : 'HEAD_IMG_LOCAL_URL'
                            });
                      },
                      onQueueComplete : function(queueData) {
                        var win = frameElement.api.opener;
                        win.reloadTable();
                        win.tip(serverMsg);
                        frameElement.api.close();
                      },
                      onUploadSuccess : function(file, data, response) {
                        var d = $.parseJSON(data);
                        if (d.success) {
                          var win = frameElement.api.opener;
                          serverMsg = d.msg;
                        }
                      },
                      onFallback : function() {
                        tip("您未安装FLASH控件，无法上传图片！请安装FLASH控件后再试")
                      },
                      onSelectError : function(file, errorCode, errorMsg) {
                        switch (errorCode) {
                        case -100:
                          tip("上传的文件数量已经超出系统限制的"
                              + $('#file').uploadify('settings',
                                  'queueSizeLimit') + "个文件！");
                          break;
                        case -110:
                          tip("文件 ["
                              + file.name
                              + "] 大小超出系统限制的"
                              + $('#file').uploadify('settings',
                                  'fileSizeLimit') + "大小！");
                          break;
                        case -120:
                          tip("文件 [" + file.name + "] 大小异常！");
                          break;
                        case -130:
                          tip("文件 [" + file.name + "] 类型不正确！");
                          break;
                        }
                      },
                      onUploadProgress : function(file, bytesUploaded,
                          bytesTotal, totalBytesUploaded, totalBytesTotal) {
                      }
                    });
              });
            </script>
						<span id="file_uploadspan"><input type="file"
							name="headImgLocalUrl" id="headImgLocalUrl" /></span>
					</div>
					<div class="form" id="filediv_file"></div> <span
					class="Validform_checktip"></span> <label class="Validform_label"
					style="display: none;">头像本地地址</label>
				</td>
			<tr>
				<td align="right"><label class="Validform_label"> 备注: </label>
				</td>
				<td class="value"><input id="remark" name="remark" type="text"
					style="width: 150px" class="inputxt"> <span
					class="Validform_checktip"></span> <label class="Validform_label"
					style="display: none;">备注</label></td>
			</tr>
		</table>
	</t:formvalid>
</body>
<script
	src="webpage/com/gomore/wechat/module/kefu/account/wxKfAccount.js"></script>
<script type="text/javascript">
  function beforeSubmit() {
    if ($('#password').val() != $('#confirmpwd').val()) {
      alert('两次输入的密码不一致');
      return false;
    }
    return true;
  }

  function jeecgFormFileCallBack(data) {
    if (data.success == true) {
      uploadFile(data);
    } else {
      if (data.responseText == '' || data.responseText == undefined) {
        $.messager.alert('错误', data.msg);
        $.Hidemsg();
      } else {
        try {
          var emsg = data.responseText.substring(data.responseText
              .indexOf('错误描述'), data.responseText.indexOf('错误信息'));
          $.messager.alert('错误', emsg);
          $.Hidemsg();
        } catch (ex) {
          $.messager.alert('错误', data.responseText + '');
        }
      }
      return false;
    }
    if (!neibuClickFlag) {
      var win = frameElement.api.opener;
      win.reloadTable();
    }
  }
  function upload() {
    $('#headImgLocalUrl').uploadify('upload', '*');
  }

  var neibuClickFlag = false;
  function neibuClick() {
    neibuClickFlag = true;
    $('#btn_sub').trigger('click');
  }
  function cancel() {
    $('#headImgLocalUrl').uploadify('cancel', '*');
  }
  function uploadFile(data) {
    if (!$("input[name='id']").val()) {
      if (data.obj != null && data.obj != 'undefined') {
        $("input[name='id']").val(data.obj.id);
      }
    }
    if ($(".uploadify-queue-item").length > 0) {
      upload();
    } else {
      if (neibuClickFlag) {
        alert(data.msg);
        neibuClickFlag = false;
      } else {
        var win = frameElement.api.opener;
        win.reloadTable();
        win.tip(data.msg);
        frameElement.api.close();
      }
    }
  }
</script>